package com.mzy.linear_struct.subject;

import com.mzy.linear_struct.ArrayStack;

/**
 * @Author: codermzy
 * @Date: 2024/03/26/19:50
 * @Description: 十进制转二进制
 */
public class DecimalToBinary {

    public static void solution(int num) {
        int n = num;
        ArrayStack<Integer> stack = new ArrayStack<>(64);
        while (n != 0) {
            int bit = n % 2;
            stack.push(bit);
            n >>= 1;
        }
        while (stack.peek() != null) {
            System.out.print(stack.pop());
        }
    }

    public static void main(String[] args) {
        solution(35);
    }
}
